<template>
    <div class="recommend">
        <van-pull-refresh v-model="isLoading" @refresh="onRefresh">
            <lazy-component>
                <Post v-for="(post,index) in list" :key="index" :post="post" :isGroup="false" v-lazy="post"/>
            </lazy-component>
        </van-pull-refresh>
    </div>
</template>

<script>
import axios from 'axios'
import jwtDecode from 'jwt-decode'
import Post from '../common/post/Post.vue'
import { PullRefresh } from 'vant';//下拉刷新
export default {
    name:'Recommend',
    components:{
        Post
    }, 
    data() { 
        return {
            list:null,
            decode:null,
            isLoading:false
        }
    },
    mounted() {
        // let token=JSON.parse(sessionStorage.getItem("token"))
        // this.decode = jwtDecode(token);
        // this.getInfo()
        this.list = [
            {
                bodyId: 34,
                classname: "交流圈子",
                collection: 17,
                content: "动漫分享",
                img: "https://img1.baidu.com/it/u=2157140368,217465291&fm=26&fmt=auto",
                imgs: `https://img1.baidu.com/it/u=1747767070,1424143368&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=600;
                https://img2.baidu.com/it/u=1301228462,3320080494&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=746;
                https://img0.baidu.com/it/u=977364321,3979352488&fm=253&fmt=auto&app=138&f=JPEG?w=711&h=500;
                https://img1.baidu.com/it/u=2799489080,2639126132&fm=253&fmt=auto&app=138&f=JPEG?w=707&h=500;
                https://img1.baidu.com/it/u=3437280624,3393774297&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=871;
                https://img2.baidu.com/it/u=2573239513,2769423833&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=727;
                https://img0.baidu.com/it/u=3721396657,2943407387&fm=253&fmt=auto&app=138&f=JPEG?w=640&h=453;
                https://img1.baidu.com/it/u=1522722903,2609411280&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=710;
                https://img2.baidu.com/it/u=4107843859,3401709685&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=889
                `,
                nickname: "动漫",
                praise: 294,
                state: 0,
                time: "2022-03-31 19:45:31",
                userId: 11,
            },
            {
                bodyId: 34,
                classname: "交流圈子",
                collection: 12,
                content: "111",
                img: "https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fb-ssl.duitang.com%2Fuploads%2Fitem%2F201610%2F31%2F20161031110955_TJKiw.thumb.700_0.jpeg&refer=http%3A%2F%2Fb-ssl.duitang.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1651479686&t=65a669130ee5a0191fa8f3fc660b1160",
                imgs: "https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fb-ssl.duitang.com%2Fuploads%2Fitem%2F201701%2F03%2F20170103132147_ahdkQ.jpeg&refer=http%3A%2F%2Fb-ssl.duitang.com&app=2002&size=f999910000&q=a80&n=0&g=0n&fmt=auto?sec=1651479686&t=8890337ccdd198dca270e32d56205641,https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fimg.lemeitu.com%2Fm00%2Fc9%2F59%2F5e77d24e00349caf34a919bf869a7be6__w.jpg&refer=http%3A%2F%2Fimg.lemeitu.com&app=2002&size=f999910000&q=a80&n=0&g=0n&fmt=auto?sec=1651479685&t=edb2d0acaa5eb1d965f553d9277c835a,https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fwww.zzvips.com%2Fuploads%2Fallimg%2F191126%2F223U26262-8.jpg&refer=http%3A%2F%2Fwww.zzvips.com&app=2002&size=f999910000&q=a80&n=0&g=0n&fmt=auto?sec=1651479686&t=024f79b1cdb26496abdeb550841586b4",
                nickname: "地球",
                praise: 14,
                state: 0,
                time: "2022-03-28 19:45:31",
                userId: 11,
            },
            {
                bodyId: 34,
                classname: "交流圈子",
                collection: 12,
                content: "日出",
                img: "https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fimg.lemeitu.com%2Fm00%2Fc9%2F59%2F5e77d24e00349caf34a919bf869a7be6__w.jpg&refer=http%3A%2F%2Fimg.lemeitu.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1651479685&t=edb2d0acaa5eb1d965f553d9277c835a",
                imgs: "https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fimg.lemeitu.com%2Fm00%2Fc9%2F59%2F5e77d24e00349caf34a919bf869a7be6__w.jpg&refer=http%3A%2F%2Fimg.lemeitu.com&app=2002&size=f999910000&q=a80&n=0&g=0n&fmt=auto?sec=1651479685&t=edb2d0acaa5eb1d965f553d9277c835a,https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fwww.zzvips.com%2Fuploads%2Fallimg%2F191126%2F223U26262-8.jpg&refer=http%3A%2F%2Fwww.zzvips.com&app=2002&size=f999910000&q=a80&n=0&g=0n&fmt=auto?sec=1651479686&t=024f79b1cdb26496abdeb550841586b4",
                nickname: "图片集",
                praise: 14,
                state: 0,
                time: "2022-03-28 19:45:31",
                userId: 11,
            },
        ]
    },
    methods: { 
        onRefresh() {
            let that = this
            async function test(){
                let data = await axios({
                    url:'/body/findAll',
                    method:'get',
                    params:{
                        // userId:String(this.decode.userId)
                    },
                    // headers:{
                    //     'Authentication-Token':''
                    // }
                })
                if(data.data.code === 20000){
                    data.data.data.imgs = `https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fwtkoss.weituk.com%2Fwp-content%2Fuploads%2F2020%2F01%2FIMG_3849.jpg&refer=http%3A%2F%2Fwtkoss.weituk.com&app=2002&size=f999910000&q=a80&n=0&g=0n&fmt=auto?sec=1651479686&t=f9a16d4ef70eade459c82bbea73c8ce35,https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fpic1.win4000.com%2Fmobile%2F2020-02-19%2F5e4cd114ddca1.jpg&refer=http%3A%2F%2Fpic1.win4000.com&app=2002&size=f999910000&q=a80&n=0&g=0n&fmt=auto?sec=1651479686&t=e023467fcb11b178ca252b254037d60b,https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fwww.soumeitu.com%2Fwp-content%2Fuploads%2F2020%2F02%2F5e42368533f46.jpg&refer=http%3A%2F%2Fwww.soumeitu.com&app=2002&size=f999910000&q=a80&n=0&g=0n&fmt=auto?sec=1651479686&t=ea4072a84561b93d95dc1c9e9aacc6bf,https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fwww.zzvips.com%2Fuploads%2Fallimg%2F191126%2F223U260Y-2.jpg&refer=http%3A%2F%2Fwww.zzvips.com&app=2002&size=f999910000&q=a80&n=0&g=0n&fmt=auto?sec=1651479686&t=c6d188d5e21501a94a1d98512a8bcf4f,https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fupload-images.jianshu.io%2Fupload_images%2F26702071-99df6520cc7c4a52.jpg&refer=http%3A%2F%2Fupload-images.jianshu.io&app=2002&size=f999910000&q=a80&n=0&g=0n&fmt=auto?sec=1651479686&t=4840b6f52f3449763643023baf5d8b5f,https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fb-ssl.duitang.com%2Fuploads%2Fitem%2F201610%2F18%2F20161018154140_LrvVN.jpeg&refer=http%3A%2F%2Fb-ssl.duitang.com&app=2002&size=f999910000&q=a80&n=0&g=0n&fmt=auto?sec=1651479686&t=9e483273fc543b1fbb71d80217bebd76,
                https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fc-ssl.duitang.com%2Fuploads%2Fitem%2F201701%2F03%2F20170103132202_i2Y5A.thumb.1000_0.jpeg&refer=http%3A%2F%2Fc-ssl.duitang.com&app=2002&size=f999910000&q=a80&n=0&g=0n&fmt=auto?sec=1651479686&t=953e80ae0f06b4291c0e97caf515fdbb,
                https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fb-ssl.duitang.com%2Fuploads%2Fitem%2F201703%2F07%2F20170307160239_kQMas.thumb.700_0.jpeg&refer=http%3A%2F%2Fb-ssl.duitang.com&app=2002&size=f999910000&q=a80&n=0&g=0n&fmt=auto?sec=1651479686&t=c9ec0fe407f024c16d02f79e010f6679,
                https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fimg9.51tietu.net%2Fpic%2F2019-091212%2Fqugo5dowqjwqugo5dowqjw.jpg&refer=http%3A%2F%2Fimg9.51tietu.net&app=2002&size=f999910000&q=a80&n=0&g=0n&fmt=auto?sec=1651479686&t=4756dc60a606236958a8984f2f860b55
                `
                    that.list = data.data.data
                    that.isLoading = false;
                }
            }
            test()
        },
        getInfo(){
            axios({
                url:'/body/findAll',
                method:'get',
                params:{
                    // userId:String(this.decode.userId)
                }
            }).then(data=>{
                console.log(data)
                this.list = data.data.data
            }).catch(err=>{
                console.log(err) 
            })
        }
    },
}
</script>

<style>
    .recommend{
        background-color: #fafafa;
        /* height: 100%; */
    }
</style>